<template>
    <view class="container">
        <view class="scan" @click="clickScan">
            <image src="/static/images/scan.png" mode="scaleToFill" />
            <view>扫码收款</view>
        </view>
    </view>
</template>
<script lang="ts" setup>
import { handleJump } from '@/utils/common';
// import { Toast } from '@/utils/uniapi/prompt';
// import { getCurrentInstance } from 'vue';
const scanner = uni.requireNativePlugin('Ba-Scanner');
onLoad(() => {});
onShow(() => {});

const clickScan = () => {
    console.log(scanner);
    scanner.onScan(
        {
            isContinuous: true,
            barcodeFormats: ['QR Code'],
            scanTimeSpace: 2000,
            isShowVibrate: true,
            isShowBeep: true,
            isShowToast: false,
        },
        (ret) => {
            console.log(ret);
            onClose();
            if (ret.result) {
                handleJump('MemberConsume', { code: ret.result });
                // Toast(ret.result);
            }
        },
    );
};
const onClose = () => {
    scanner.onClose();
};
</script>
<style lang="scss">
.scan {
    padding-top: 200rpx;
    text-align: center;
    image {
        width: 200rpx;
        height: 200rpx;
        margin: 0 auto;
    }
}
</style>
